home *** CD-ROM | disk | FTP | other *** search
- /* Options.c
- * Handle options dialog for Writeswell Jr.
- * ©1992 Working Software, Inc.
- * This source code is copyrighted. Permission is granted to use the Word Services
- * portion of the Writeswell Jr. source code in your own programs, but you
- * may not distribute the Writeswell Jr. word-processor code as a
- * commercial product. If you modify the code, please do not call it
- * Writeswell Jr. (or Writeswell.) This will ensure that people understand the
- * program and don’t have to deal with a number of different versions with
- * who-knows-what going on in the code.
- *
- * Writeswell Jr. and Writeswell are trademarks of Working Software, Inc.
- * 18 Aug 92 Mike Crawford
- */
-
- #include "TBConstants.h"
- #include "TBGlobals.h"
- #include "OutlineButton.h"
- #include "Options.h"
- #include "Prefs.h"
- #include "Gripe.h"
-
- void OptionsDialog( void )
- {
- DialogPtr optDlg;
- short item;
- short kind;
- Handle h;
- Rect r;
- Boolean sendByList;
- ControlHandle listHdl;
- ControlHandle tblHdl;
- WWJrPrefsHdl prefHdl;
- UserItemUPP outlineUPP;
-
- prefHdl = GetPrefHandle();
- if ( !prefHdl ){
- Gripe( "\pCannot get preferences handle" );
- return;
- }
-
- optDlg = GetNewDialog( rOptionsID, (Ptr)NULL, (WindowPtr)-1 );
- if ( !optDlg )
- return;
-
- GetDItem( optDlg, kODSendText, &kind, (Handle *) &listHdl, &r );
- GetDItem( optDlg, kODSendTable, &kind, (Handle *) &tblHdl, &r );
-
- /* Set up a user proc to draw the default outline */
-
- GetDItem( optDlg, kODDefUser, &kind, &h, &r );
-
- outlineUPP = NewUserItemProc( OutlineButton );
- if ( !outlineUPP )
- return; // STUB should report an error
-
- SetDItem( optDlg, kODDefUser, kind, (Handle)outlineUPP, &r );
-
- sendByList = (*prefHdl)->sendByList;
-
- if ( sendByList )
- SetCtlValue( listHdl, 1 );
- else
- SetCtlValue( tblHdl, 1 );
-
- do {
- ModalDialog( (ModalFilterUPP)NULL, &item );
-
- switch ( item ){
- case kODSendText:
- sendByList = true;
- SetCtlValue( listHdl, 1 );
- SetCtlValue( tblHdl, 0 );
- break;
- case kODSendTable:
- sendByList = false;
- SetCtlValue( listHdl, 0 );
- SetCtlValue( tblHdl, 1 );
- break;
- }
- } while ( item != kODCancel && item != kODOk );
-
- #ifdef GENERATINGCFM
- DisposeRoutineDescriptor( outlineUPP );
- #endif
-
- if ( item == kODCancel ){
- DisposDialog( optDlg );
- return;
- }
-
- (*prefHdl)->sendByList = sendByList;
-
- ChangedResource( (Handle) prefHdl );
- WriteResource( (Handle) prefHdl );
-
- DisposDialog( optDlg );
-
- return;
- }